<template>
  <div>
    <el-form
      ref="ruleFormRef"
      status-icon
      :rules="rules"
      label-width="120px"
      class="demo-ruleForm"
    >
      <el-form-item label="原密码" prop="oldPassword">
        <el-input v-model="oldPassword" autocomplete="off" />
      </el-form-item>
      <el-form-item label="新密码" prop="newPassword">
        <el-input v-model="newPassword" autocomplete="off" />
      </el-form-item>
      <el-form-item label="确认密码" prop="oldPasswordss">
        <el-input v-model="oldPasswordss" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="Cancels">取消</el-button>
        <el-button @click="resetForm">确定</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import axios from "axios";
import { ElMessage as $msg } from "element-plus";
import cookin from "js-cookie";
import QS from "qs"; //创建文件自带插件，可以直接引用(转型)
import router from "@/router";
import http from "@/http";
export default {
  data() {
    return {
      oldPassword: "",
      newPassword: "",
      oldPasswordss: "",
    };
  },
  methods: {
    resetForm() {
      if (this.oldPassword == "") {
        $msg.success("原密码不能为空!");
        return;
      }
      if (this.newPassword == "") {
        $msg.success("新密码不能为空!");
        return;
      }
      if (this.newPassword !== this.oldPasswordss) {
        $msg.success("二次输入密码不一致");
        return;
      }
      const data = {
        _gp: "admin",
        _mt: "newPassword",
        oldPassword: this.oldPassword,
        newPassword: this.newPassword,
      };
      this.oldPasswordss;

      http.post(data).then((res) => {
        let { data, errno, errmsg } = res;
        console.log(res);
        if (200 == res.errno) {
          $msg.success("修改成功");
          this.$router.push("/login");
        }
      });
    },
  },
};
</script>
<style lang="less" scoped>
/deep/ .el-input__inner {
  width: 290px;
}
span {
  display: inline-block;
}
</style>
